package com.xiaozhengkeji.modok.events;

import com.xiaozhengkeji.modok.utils.ItemUtils;
import com.xiaozhengkeji.modok.utils.MsgUtils;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;

public class CoreEvent implements Listener {
    //进服

    @EventHandler
    public void onPlayerJoinServer(PlayerJoinEvent event) {
        Player p = event.getPlayer();
        MsgUtils.logServer("玩家进服,数据同步中!");
        ItemUtils utils = new ItemUtils();
        utils.givePlayerItemsByRedis(p);
        MsgUtils.logServer("玩家进服,数据同步完成!");
    }

    //退服

    @EventHandler
    public void onPlayerQuitEvent(PlayerQuitEvent event) {
        Player p = event.getPlayer();
        MsgUtils.logServer("玩家退服,数据同步中!");
        ItemUtils utils = new ItemUtils();
        utils.playerItemToRedis(p);
        MsgUtils.logServer("玩家退服,数据同步完成!");
    }
}
